package junit.test.demo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import com.gohi.main.util.StringUtil;
import com.gohi.main.util.Utils;

public class testDate {
	public static void main(String[] args) throws ParseException {
		String time  =  StringUtil.parentSimple(1429700400, "yyyy-MM-dd HH:mm");
		System.err.println(time);
		System.err.println(60*1000*60);
		 time  =  StringUtil.parentSimple(1429700400+60*60, "yyyy-MM-dd HH:mm");
		System.err.println(time);
		
		return ;
		
		//yyyy-MM-dd 

		/*String time1  =  StringUtil.parentSimple(1429797600, "HH:mm");
		

		//System.err.println();
	    System.err.println(time+"\t"+time1);
		
		//getNextYear(time,time1,120);
		
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		
		 Date dt = Utils.parseFormatted("2015-04-22 12:30", "yyyy-MM-dd HH:mm");
		 System.err.println(dt.getTime()/1000);
		 GregorianCalendar c = new GregorianCalendar();
		 c.setTime(dt);
		 c.add(12,-60);
		 System.err.println(c.getTime().getTime()/1000);
		 */
		 
		 
		 
		 
		 
		 
	}
	/**
	 * 
	 * @param stime开始时间
	 * @param etime结束时间
	 * @param hour 套餐时间
	 * @return
	 * @throws ParseException
	 */
	public static String getNextYear(String stime, String etime,int hour) throws ParseException {
		SimpleDateFormat sf = new SimpleDateFormat("HH:mm");
		Date date = sf.parse(etime);
	    GregorianCalendar c = new GregorianCalendar();  
		c.setTime(date);
	    c.add(12,-hour);
		Date dt1=c.getTime(); //计算套餐结束时间 
		
		date=  sf.parse(stime);//计算套餐开始时间
	    //先加上开始时间
		String reslut =sf.format(date)+"-";
		c.setTime(date);
		//从开始时间循环到结束时间 以半小时间隔
		while(!sf.format(c.getTime()).equals(sf.format(dt1))){
			c.setTime(c.getTime());
			c.set(Calendar.MINUTE,(c.get(Calendar.MINUTE) + 30));
			reslut=reslut+sf.format(c.getTime())+"-";
			//System.err.println(sf.format(c.getTime()));
		}
		return reslut;
	}
}
